package com.xin.data.simbapesa.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;

import com.xin.data.simbapesa.api.U;


public class SpUtils {

    private static final String NAME = U.URL_MAIN_PRODUCT + "_shared";

    public static final String KEY_TIME = "TIME_JSON";

    public static final String KEY_APP_INFO = "APP_INFO";


    public static final String KEY_USERID = "KEY_USERID";

    public static final String KEY_TOKEN = "KEY_TOKEN";

    public static final String KEY_PHONE = "KEY_PHONE";

    public static final String KEY_TYPE = "KEY_TYPE";

    public static final String KEY_ISADSOURCE = "KEY_ISADSOURCE";


    public static final String KEY_SMS_PERMISSION = "KEY_SMS_PERMISSION";

    public static final String KEY_CAMERA_PERMISSION = "KEY_CAMERA_PERMISSION";

    public static final String KEY_IMG_PERMISSION = "KEY_IMG_PERMISSION";

    public static final String KEY_PHOTO = "KEY_PHOTO";

    public static final String KEY_BIRTH = "KEY_BIRTH";


    public static final String KEY_REPAYDOT = "KEY_REPAYDOT";

    public static final String KEY_SCORE_NUM = "KEY_SCORE_NUM";

    public static final String KEY_CASH_AMOUNT = "KEY_CASH_AMOUNT";

    public static final String KEY_VIP = "KEY_VIP";


    public static final String KEY_GUIDE = "KEY_GUIDE";

    public static final String KEY_TAG = "KEY_TAG";

    public static final String KEY_CURRENCY = "KEY_CURRENCY";


    public static final String KEY_POINTLIST_ID = "KEY_POINTLIST_ID";

    public static final String KEY_UPDATE ="KEY_UPDATE";

    public static void save_string(Context context, String key, String data) {
        SharedPreferences preferences = context.getSharedPreferences(NAME, 0);
        preferences.edit().putString(key, data).apply();
    }

    public static String get_string(Context context, String key, String data) {
        if (context == null || TextUtils.isEmpty(key)) {
            return "";
        }
        SharedPreferences preferences = context.getSharedPreferences(NAME, 0);
        return preferences.getString(key, "");
    }

    public static void save_boolean(Context context, String key, boolean data) {
        SharedPreferences preferences = context.getSharedPreferences(NAME, 0);
        preferences.edit().putBoolean(key, data).apply();
    }

    public static boolean get_boolean(Context context, String key) {
        SharedPreferences preferences = context.getSharedPreferences(NAME, 0);
        return preferences.getBoolean(key, false);
    }

    public static void save_int(Context context, String key, int data) {
        SharedPreferences preferences = context.getSharedPreferences(NAME, 0);
        preferences.edit().putInt(key, data).apply();
    }

    public static int get_int(Context context, String key) {
        SharedPreferences preferences = context.getSharedPreferences(NAME, 0);
        return preferences.getInt(key, 0);
    }

}
